<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="script/jquery.js"></script>
    <style>
        img{
            width: 640px;
            height: 320px;
        }

        .active{
            background-color:aquamarine;
        }
    </style>
</head>
<body>
    <img src="./images/1.png" alt="">
    <div class = "btnList">
        <button class = "active">1</button>
        <button>2</button>
        <button>3</button>
    </div>
    <script>
        let imgSrc = [
            "./images/1.png",
            "./images/2.png",
            "./images/3.png"
        ]
        $("button").click(function(){
            let index = $(this).index()
            // attr("属性","属性值")
            $("img").attr("src",imgSrc[index])
            // 添加class addClass("")设置背景色
            // $(this).addClass("active")
            // 删除背景色 removeClass("")
            // $(this).removeClass("active")
            // 切换css 有就删除没有就添加 toggleClass("")
            // $(this).toggleClass("active")

            // 找到同级的，同一时间只有一个有css siblings()获取同级的元素
            $(this).addClass("active")
            $(this).siblings().removeClass("active")
        })
    </script>
</body>
</html>